package com.fdb.efp.nls.common.util.letter;

import java.util.Objects;

/**
 * 需求编号:2019D08--
 * 问题编号:
 * 开发人员: caoxin
 * 创建日期:2020/1/14
 * 功能描述:
 * 修改日期:2020/1/14
 * 修改描述:
 */
public class MessageFactory {
    private Message message;
    private String messageContent;
    private String[] fillIndex = {"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", "$24", "$25", "$26", "$27", "$28", "$29","$30"};

    public MessageFactory(Message message,String...args) {
        this.message = message;
        messageContent = message.getMessage();
        fillMessage(args);
    }
    private void fillMessage(String[] args) {
        if (Objects.isNull(args)) return;
        else{
            for (int i = 0; i < args.length; i++) {
                messageContent = messageContent.replace(fillIndex[i], args[i]);
            }
        }
    }

    public String getMessageContent() {
        return messageContent;
    }
}
